package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.domain.ncc.NccBasicSkuType;
import com.bzkj.basicinfo.service.ncc.NccBasicSkuTypeService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wangzhichao
 * @ClassName NccBasicSkuTypeController
 * @Date 2024/12/13 09:57:24
 * @description ncc商品分类表
 */
@Api(tags = "商品分类")
@RestController
@RequestMapping("ncc/basic/skuType")
public class NccBasicSkuTypeController extends BaseController
{
    @Autowired
    private NccBasicSkuTypeService nccBasicSkuTypeService;


    /**
     * 获取商品分类信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 10:32:17
     * @Param entity
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @RequestMapping("findSkuTypeData")
    public TableDataInfo findSkuTypeData(NccBasicSkuType entity)
    {
        startPage();
        return getDataTable(nccBasicSkuTypeService.findSkuTypeData(entity));
    }
    /**
     * 获取商品分类信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 10:32:17
     * @Param entity
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @RequestMapping("findAllSkuTypeData")
    public AjaxResult findAllSkuTypeData(NccBasicSkuType entity)
    {
        return AjaxResult.success(nccBasicSkuTypeService.findSkuTypeData(entity));
    }

    /**
     * 保存商品分类信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 10:32:57
     * @Param entity
     */
    @ApiOperation("新增接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:add')")
    @PostMapping("saveSkuType")
    @LogC(title = "ncc商品分类信息", businessType = BusinessType.INSERT,
            tableNames = "ncc_basic_sku_type", pkFieldNames = "id", content = "' 商品类型名称：'+#entity.nccStuName")
    public AjaxResult saveSkuType(@RequestBody NccBasicSkuType entity)
    {
        return nccBasicSkuTypeService.saveSkuType(entity);
    }

    /**
     * 修改商品分类状态
     *
     * @Author wangzhichao
     * @Date 2024/12/13 10:33:18
     * @Param status
     * @Param pkMarbasclass
     */
    @ApiOperation("修改状态接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:stateEdit')")
    @PutMapping("updateSkuTypeEnableStatus")
    @LogC(title = "ncc商品分类信息", businessType = BusinessType.UPDATE,
            tableNames = "ncc_basic_sku_type", pkFieldNames = "pk_marbasclass", content = "' 商品分类主键：'+#pkMarbasclass")
    public AjaxResult updateSkuTypeEnableStatus(@RequestParam String status, @RequestParam String pkMarbasclass)
    {
        return nccBasicSkuTypeService.updateSkuTypeEnableStatus(status, pkMarbasclass);
    }

    /**
     * 修改商品信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 10:33:33
     * @Param entity
     */
    @ApiOperation("修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:edit')")
    @PutMapping("updateSkuType")
    @LogC(title = "ncc商品分类信息", businessType = BusinessType.UPDATE,
            tableNames = "basic_sku_type", pkFieldNames = "pk_marbasclass", content = "' 商品类型名称：'+#entity.nccStuName")
    public AjaxResult updateSkuType(@RequestBody NccBasicSkuType entity)
    {
        return nccBasicSkuTypeService.updateSkuType(entity);
    }

    /**
     * 获取所有商品分类数据
     *
     * @Author wangzhichao
     * @Date 2024/12/17 19:59:07
     */
    @ApiOperation("查询物料分类下拉接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBasicSkuTypeAll")
    public R findNccBasicSkuTypeAll()
    {
        return nccBasicSkuTypeService.findNccBasicSkuTypeAll();
    }

    /**
     * 根据类型名称模糊查询类型列表
     *
     * @param name
     * @return
     */
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBasicSkuTypeNameList")
    public List<String> findNccBasicSkuTypeNameList(String name)
    {
        return nccBasicSkuTypeService.findNccBasicSkuTypeNameList(name);
    }

    /**
     * 定时获取商品分类数据
     * 获取当天
     *
     * @return
     */
    @GetMapping("jobMethodExecute")
    public AjaxResult jobMethodExecute()
    {
        return nccBasicSkuTypeService.jobMethodExecute(false);
    }

    @DeleteMapping("/delete")
    public AjaxResult deleteById(String id){
        return nccBasicSkuTypeService.deleteBasicSkuTypeById(id);
    }

}